package com.ruoyi.common.core.suanfa;

/**
 *
 * 样例  1:
 * 	输入:  [3, 2, 1, 4, 5]
 * 	输出:  [1, 2, 3, 4, 5]
 *
 * 	样例解释:
 * 	返回排序后的数组。
 *
 */
public class Sort {
    public static void sortInt(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                break;
            }
            for (int j = i; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }


    public static void main(String[] args) {
        int[] ints = {3, 2, 1, 4,3, 5,9,5,6,7,8};
        sortInt(ints);
        for (int anInt : ints) {
            System.out.println(anInt);
        }
    }
}
